class Article < ActiveRecord::Base

  default_scope :order => "articles.updated_at desc"

  scope :get_status, lambda {|status| {:conditions => ["status = ?",status] }}

  belongs_to :user
  belongs_to :category

  #  has_many :comments, :as => :object, :class_name => "Comment"
  acts_as_taggable


  def self.get_status_types
    [ ['已发布', 'publish'], ['等待复审', 'pending'], ['草稿', 'draft']]
  end

  def get_status
    Hash[ *Article.get_status_types.collect { |v| [v[1],v[0]] }.flatten ][self.status]
  end

  def self.get_comment_status_types
    [ ['开启', 'open'], ['关闭', 'closed']]
  end

  def get_comment_status
    Hash[ *Article.get_comment_status_types.collect { |v| [v[1],v[0]] }.flatten ][self.comment_status]
  end

end
